<template>
  <el-container class="indexLayout">
    <el-header>
      <div class="bigTitle"><span>电子书管理平台</span></div>
      <div class="toolbar">
        <el-dropdown class="user-dropDown">
          <el-icon style="margin-right: 8px; margin-top: 1px">
            <setting />
          </el-icon>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item @click="handleIndexDetail"
                >详细信息</el-dropdown-item
              >
              <el-dropdown-item @click="handleIndexLogin"
                >登录</el-dropdown-item
              >
              <el-dropdown-item @click="handleIndexLogout"
                >退出登录</el-dropdown-item
              >
            </el-dropdown-menu>
          </template>
        </el-dropdown>
        <span class="headerUserName">{{ userStore.getUserName() }}</span>
      </div>
    </el-header>
    <el-container>
      <el-aside width="200px">
        <!-- 常用router进行高亮指定，会子自动根据index值进行获取 -->
        <el-menu router :default-active="$route.path">
          <el-menu-item
            v-for="item in asideMsg"
            :key="item.navigateTo"
            :index="item.navigateTo"
          >
            <template #title>
              <el-icon><message /></el-icon>{{ item.title }}
            </template>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-main>
        <RouterView />
      </el-main>
    </el-container>
    <div class="footerInfo">
      <span>底边栏目的信息</span>
    </div>
  </el-container>
</template>

<script lang="js" setup>
import { useUserStore } from "@/store/auth/userStore.js";
import { useSystemStore } from "@/store/system/systemStore.js";
import router from "@/router";
const systemStore = useSystemStore();
const userStore = useUserStore();

const asideMsg = [
  // { title: "测试", navigateTo: "/test" },
  // { title: "模拟登录", navigateTo: "/tlogin" } , // 测试结束
  { title: "登录页面", navigateTo: "/login" },
  { title: "个人信息", navigateTo: "/index" },
  { title: "系统信息管理", navigateTo: "/index/properties" },
  { title: "用户管理", navigateTo: "/index/user" },
  { title: "书本管理", navigateTo: "/index/contribute" },
  { title: "书籍评论", navigateTo: "/index/comment" },
  { title: "书籍审核列表", navigateTo: "/index/contributejudge" },
  { title: "评论审核列表", navigateTo: "/index/commentjudge" },
];

/**
 * 查看用户详细信息
 */
const handleIndexDetail = ()=>{
  console.log("handleIndexDetail");
  router.push({ path: "/index" });
}
const handleIndexLogin = ()=>{
  console.log("handleIndexLogin");
  router.push({ path: "/login" });
}
const handleIndexLogout = ()=>{
  console.log("handleIndexLogout");
  router.push({ path: "/login" });
  userStore.logout();
}
</script>

<style lang="scss" scoped>
.indexLayout {
  min-height: calc(100vh - 20px);
  background-color: rgb(232, 233, 236);
  border-radius: 10px;
  .el-header {
    margin: 10px;
    display: flex;
    justify-content: space-between; /* 此条控制header的内容是靠两边排布的*/
    font-size: 12px;
    border-radius: 10px;
    background-color: rgb(50, 51, 59);
    color: var(--el-text-color-primary);

    .bigTitle {
      margin: 5px;
      border-radius: 10px;
      color: white;
      background-color: $primary-color;
      font-size: 24px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 5px;
    }
  }
  .toolbar {
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    right: 20px;
  }
  .el-aside {
    margin: 10px;
    border-radius: 10px;
    height: 100%;
    width: 300px;
    color: var(--el-text-color-primary);
    background: var(--el-color-primary-light-8);
    // MARK 此处无法使用SCSS变量，只能使用CSS变量，原因不明
    --el-menu-bg-color: var(--primary-color);
    --el-menu-text-color: black;
    --el-menu-active-color: white;
  }

  .el-main {
    margin: 10px;
    padding: 0;
  }
  .footerInfo {
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}

.indexLayout {
  .el-menu {
    border-right: none;
  }
}

.user-dropDown {
}
</style>
